package com.rc.saas.mini.service.ugs;

import com.rc.saas.mini.mapper.ugs.TenantUgsLevelTypeMapper;
import com.rc.saas.mini.model.ugs.TenantUgsLevelType;
import com.rc.saas.mini.model.ugs.TenantUgsLevelTypeExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TenantUgsLevelTypeServiceImpl implements TenantUgsLevelTypeService {

    @Autowired
    private TenantUgsLevelTypeMapper tenantUgsLevelTypeMapper;

    @Override
    public TenantUgsLevelTypeMapper getMapper() {
        return tenantUgsLevelTypeMapper;
    }

    @Override
    public TenantUgsLevelType selectByLevelType(String tenantCode, String levelType) {
        TenantUgsLevelTypeExample example = new TenantUgsLevelTypeExample();//Status 状态 0启用 1停用 默认0
        example.createCriteria().andTenantCodeEqualTo(tenantCode).andLevelTypeEqualTo(levelType).andStatusEqualTo("0");
        return tenantUgsLevelTypeMapper.selectByExample(example).stream().findFirst().orElseGet(() -> null);
    }

    @Override
    public List<TenantUgsLevelType> listByTenantCode(String tenantCode) {
        TenantUgsLevelTypeExample example = new TenantUgsLevelTypeExample();
        //Status 状态 0启用 1停用 默认0
        example.createCriteria().andTenantCodeEqualTo(tenantCode).andStatusEqualTo("0");
        example.setOrderByClause(" sort asc");
        return tenantUgsLevelTypeMapper.selectByExample(example);
    }
}
